/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.utl.ist.isr.livetrack.ui;

import java.awt.Image;
import java.awt.event.ActionEvent;
import javax.swing.Action;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.util.HelpCtx;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.actions.SystemAction;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public class ServersNode extends AbstractNode {

    private Action[] actions = new Action[]{
        new SystemAction() {

            @Override
            public String getName() {
                return NbBundle.getMessage(this.getClass(), "NewServerAction");
            }

            @Override
            public HelpCtx getHelpCtx() {
                return null;
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
                new NewServerWizardAction().actionPerformed(null);
            }
        },
        new SystemAction() {

            @Override
            public String getName() {
                return NbBundle.getMessage(this.getClass(), "RefreshServersAction");
            }

            @Override
            public HelpCtx getHelpCtx() {
                return null;
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
//                ServersNode cn = Utilities.actionsGlobalContext().lookup(ServersNode.class);
                ServersNodeChildFactory.getInstance().refresh();
            }
        }
    };

    public ServersNode() {
        super(Children.create(ServersNodeChildFactory.getInstance(), false));
        setDisplayName(NbBundle.getMessage(this.getClass(), "ServersNode_title"));
    }

    public Image getIcon(int type) {
        return ImageUtilities.loadImage("pt/utl/ist/isr/livetrack/ui/icons/world.png", true);
    }

    @Override
    public Image getOpenedIcon(int type) {
        return getIcon(type);
    }

    @Override
    public Action[] getActions(boolean context) {
        return actions;
    }
}
